{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Delete Middle Node LCCI"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #LCCI"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #linked-list"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #链表"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: deleteNode"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #删除中间节点"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>若链表中的某个节点，既不是链表头节点，也不是链表尾节点，则称其为该链表的「中间节点」。</p>\n",
    "\n",
    "<p>假定已知链表的某一个中间节点，请实现一种算法，将该节点从链表中删除。</p>\n",
    "\n",
    "<p>例如，传入节点 <code>c</code>（位于单向链表 <code>a->b->c->d->e->f</code> 中），将其删除后，剩余链表为 <code>a->b->d->e->f</code></p>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>示例：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>节点 5 （位于单向链表 4->5->1->9 中）\n",
    "<strong>输出：</strong>不返回任何数据，从链表中删除传入的节点 5，使链表变为 4->1->9\n",
    "</pre>\n",
    "\n",
    "<p> </p>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [delete-middle-node-lcci](https://leetcode.cn/problems/delete-middle-node-lcci/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [delete-middle-node-lcci](https://leetcode.cn/problems/delete-middle-node-lcci/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[4,5,1,9]\\n5']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next= node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val=node.next.val\n",
    "        node.next=node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        node.val = node.next.val\n",
    "        node.next=node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, c):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        c.val = c.next.val\n",
    "        c.next = c.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node1=node2=node\n",
    "        while(node1.next):\n",
    "            node1.val=node1.next.val\n",
    "            node2=node1\n",
    "            node1=node1.next\n",
    "        node2.next=None\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        p = node\n",
    "        while p.next.next:\n",
    "            p.val = p.next.val\n",
    "            p = p.next\n",
    "        p.val = p.next.val\n",
    "        p.next = None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val=node.next.val\n",
    "        node.next=node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val=node.next.val\n",
    "        node.next=node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val=node.next.val;node.next=node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, c):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        c.val = c.next.val\n",
    "        c.next = c.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val; node.next = node.next.next;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        p=node\n",
    "        q=node.next\n",
    "        while q!=None:\n",
    "            p.val=q.val\n",
    "            t=p\n",
    "            p=p.next\n",
    "            q=q.next\n",
    "        t.next=None\n",
    "        \n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "class ListNode:\n",
    "    def __init__(self, x):\n",
    "        self.val = x\n",
    "        self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "      \n",
    "        node.val=node.next.val\n",
    "        node.next=node.next.next\n",
    "   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val=node.next.val\n",
    "        node.next=node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        next_node = node.next\n",
    "        after_next_node = next_node.next\n",
    "        node.val = next_node.val\n",
    "        node.next = after_next_node\n",
    "        return "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val=node.next.val\n",
    "        node.next=node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val=node.next.val\n",
    "        node.next=node.next.next\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        #node模拟下一个节点值\n",
    "        #在将node.next改为模拟节点的下一个节点\n",
    "        #即将node的下一个节点消去\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val    #### 后面的数值拷贝过来\n",
    "        node.next = node.next.next  #### 单元也移除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val=node.next.val\n",
    "        node.next=node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        node.val = node.next.val\n",
    "        node.next = node.next.next"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# Definition for singly-linked list.\n",
    "# class ListNode:\n",
    "#     def __init__(self, x):\n",
    "#         self.val = x\n",
    "#         self.next = None\n",
    "\n",
    "class Solution:\n",
    "    def deleteNode(self, node):\n",
    "        \"\"\"\n",
    "        :type node: ListNode\n",
    "        :rtype: void Do not return anything, modify node in-place instead.\n",
    "        \"\"\"\n",
    "        cur = node\n",
    "        while cur.next and cur.next.next:\n",
    "            cur.val = cur.next.val\n",
    "            cur = cur.next\n",
    "        cur.val = cur.next.val\n",
    "        cur.next = None        \n",
    "        "
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
